package ningbo.day03.Remainder;

import java.util.Scanner;

/**
 * @Author 宁铂
 * @Date 2021/7/18 8:12
 * @Version 1.0
 */
public class TestRemainder {
    /** 本类测试取余的简单用法
     *  输入两个数(两位数和三位数)分别得出他们的每个位数
     * */

    public static void main(String[] args) {
        number1();
        //number2();
    }

    private static void number2() {
        System.out.println("请输入一个两位数:");
        int nub = new Scanner(System.in).nextInt();

        if((nub < 10) || (nub > 99)){
            System.out.println("请输入正确的两位数");
        }else{
            /** 定义两个变量来存储每个位数 */
            int x = nub%10;
            System.out.println("您输入的数字个位是: "+x);

            int y = nub/10;
            System.out.println("您输入的数字十位是: "+y);
       }
    }

    private static void number1() {
        System.out.println("请输入一个两位数:");
        int nub = new Scanner(System.in).nextInt();

        if((nub < 99) || (nub > 999)){
            System.out.println("请输入正确的两位数");
        }else{
            int x = nub % 10;
            System.out.println("您输入的数字个位是: "+x);

            int y = (nub % 100) / 10;
            System.out.println("您输入的数字十位是: "+y);

            int z = nub / 100;
            System.out.println("您输入的数字百位是: "+z);
        }
    }
}
